
/**
 * Copyright (C)  2011-2011  Jesse Meng (pingf0@gmail.com).
 *
 * This file is part of OOC-GCC.
 *
 * OOC-GCC is free software: you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library. If not, see
 * <http://www.gnu.org/licenses/>.
 */

/*
 * test_showStPart.c
 *
 *  Created on: 2011-5-21
 *      Author: Jesse Meng [pingf0@gmail.com]
 */
#include "OOStd.h"

CLASS(A){

	STATIC(A);
	int value;
	iFn show;
};
static int A_load(A *THIS,void *PARAM){

	return 0;
}
static int A_unload(A *THIS,void *PARAM){

	return 0;
}
static int A_show(A *THIS){
	printf("%s value:%d\n",__FUNCTION__,((StA*)ST(THIS))->value);
	return 0;
}
static int A_loadSt(StA *THIS,void *PARAM){
	THIS->value=100;
	THIS->show=(void *)A_show;
	return 0;
}
static int A_unloadSt(StA *THIS,void *PARAM){

	return 0;
}

ASM(A,A_load,A_unload,A_loadSt,A_unloadSt)

CLASS_EX(B,A){

	STATIC_EX(B,A);
	int value;
	iFn show;
};
static int B_load(B *THIS,void *PARAM){

	return 0;
}
static int B_unload(B *THIS,void *PARAM){

	return 0;
}
static int B_showEx(A *THIS){
	printf("%s value:%d\n",__FUNCTION__,((StA*)ST(THIS))->value);
	return 0;
}

static int B_show(B *THIS){
	printf("%s value:%d\n",__FUNCTION__,((StB*)ST(THIS))->value);
	return 0;
}

static int B_loadSt(StB *THIS,void *PARAM){
	((StA*)THIS)->value=200;
	((StA*)THIS)->show=(void *)B_showEx;
	THIS->value=300;
	THIS->show=(void *)B_show;
	return 0;
}
static int B_unloadSt(StB *THIS,void *PARAM){

	return 0;
}

ASM_EX(B,A,B_load,B_unload,B_loadSt,B_unloadSt)

int main(){
	A *a=NEW0(A);
	StA *fA=ST(a);
	B *b=NEW0(B);
	StB *fB=ST(b);
	printf("****************TEST A SHOW\n");
	fA->show(a);

	DEL0(a,A);
	printf("****************TEST B SHOW\n");
	a=NEW0(A);
	//fA=ST(a);
	fA->show(a);
	fB->StA.show(b);
	fB->show(b);
	DEL0(a,A);
	DEL0(b,B);
	return 0;
}
